<div class="edit-address clearfix">
<form class="form-horizontal  ajax-form" role="form" data-type="address" action="{:U('Scoreshop/Index/editAddress')}" method="post">
    <input type="hidden" name="goods_id" value="{$goods_id}">
    <input type="hidden" name="address_id" value="{$data['id']}">
    <div class="form-group">
        <label for="name" class="col-xs-2 control-label" style="width: 20%">{:L('_NAME_')}</label>

        <div class="col-xs-10" style="width: 60%">
            <input id="name" name="name" type="text" class="form-control"
                   value="{$data['name']}" placeholder="{:L('_NAME_')}"/>
        </div>
    </div>
    <div class="form-group">
        <label for="address" class="col-xs-2 control-label" style="width: 20%">{:L('_RECEIVING_ADDRESS_')}</label>

        <div class="col-xs-10" style="width: 60%">
            <textarea id="address" name="address" class="form-control" placeholder="{:L('_RECEIVING_ADDRESS_')}"
                      style="max-width: 310px">{$data['address']}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label for="phone" class="col-xs-2 control-label" style="width: 20%">{:L('_PHONE_NUMBER_')}</label>

        <div class="col-xs-10" style="width: 60%">
            <input id="phone" name="phone" type="text" class="form-control"
                   value="{$data['phone']}" placeholder="{:L('_PHONE_NUMBER_')}"/>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-xs-10">
            <button type="submit" class="btn btn-primary ">{:L('_SUBMIT_')}</button>
        </div>
    </div>
</form>
</div>
<script>
(function($){

  $('form[data-type="address"]').submit(function (e) {
      e.preventDefault();
      toast.showLoading();
      var self = $(this);
      $.post(self.attr("action"), self.serialize(), callback, "json");
      return false;
  });
  
  function callback(data) {
    if (data.status) {
        toast.success(data.info, '温馨提示');
        setTimeout(function () {
            $('#addressModal').modal('hide');
            modalOpen();
        }, 1000);
    }else{
        toast.error(data.info, '温馨提示');
    }
    toast.hideLoading();
  }

  function modalOpen(){
    var myModalTrigger = new $.zui.ModalTrigger({
            title : '商品兑换',
            name : 'buyModal',
            remote : "{:U('Scoreshop/index/goodsbuy',array('id'=>$goods_id))}"
        });
    myModalTrigger.show();
  }
})(jQuery);
</script>